// pages/discover/discover.js
Page({
  data:{
     motto: '欢迎',
     searchparams:'',
     imgUrls:{},
    userInfo: {},
    jobList: [
      /*  {
        id: "1",
        shopimage1url: "http://www.lgstatic.com/thumbnail_160x160/image1/M00/00/08/CgYXBlTUWA-AeZa7AACzZLV9LMM813.jpg",
        jobname: "普工",
        companyname: "佛山蓝晶领网络科有限公司",
        requrie: "年龄18岁至40岁",
        jobSalary: "3k-4k",
        createdate:"01月29日"
      }
   */
    ]
  },
 
 listClick:function(event){
 var p = event.currentTarget.id ;   
  wx.navigateTo({url:'/pages/xiangqing/xiangqing?id='+p}) 
 },
 //事件处理函数
  bindViewTap: function() {
    wx.navigateTo( {
      url: '../detail/detail'
    })
  },
    listenerSearchInput: function(e) {
      this.data.searchparams = e.detail.value;
  },
  //根据条件查询
  searchOrder:function(){
      var that=this;
      var searchparams=that.data.searchparams;     
        wx.request({
      url: 'https://lendgiant.cn/index/getjoborderlistByParams',
      data: {'searchparams':searchparams},
       header: {'Content-Type': 'application/json'},
      method: 'GET',
        success: function(result){       
        for(var j=0;j<result.data.list.length;j++){      
             if(result.data.list[j].shopimage1url != null && result.data.list[j].shopimage1url != undefined  && result.data.list[j].shopimage1url.length>0 ){
               result.data.list[j].shopimage1url='https://lendgiant.cn/'+result.data.list[j].shopimage1url
        }else{
            result.data.list[j].shopimage1url='https://lendgiant.cn/FileDB/ShopImage/noimage.jpg'
        }
      }
       that.setData({
          jobList:[]
        });
        that.setData({
          jobList:result.data.list
        });
     
      }
    });

  },
  onLoad:function(options){
     GetList(this);
    var app = getApp()
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      
      wx.request({
        url: 'https://lendgiant.cn/index/getadvertisementimage',
        data: {},
        header: { 'Content-Type': 'application/json' },
        method: 'GET',
        success: function (result) {
          that.setData({
            imgUrls: result.data.list
          });
        }
      })

      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })

  },
  onReady:function(){
    // 页面渲染完成
   // GetList(this);
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  refresh:function(event){
  // GetList(this)
 },
 onShareAppMessage: function () {
    return {
      title: '最新招聘信息',
      desc: '各大生产企业最新的招聘信息',
      path: '/pages/discover/discover'
    }
  }
})

var GetList = function(that){
      var searchparams=that.data.searchparams;
      console.log("searchparams:::"+that.data.searchparams);
        wx.request({
      url: 'https://lendgiant.cn/index/getjoborderlistByParams',
      data: {'searchparams':searchparams},
      header: {'Content-Type': 'application/json'},
      method: 'GET',
        success: function(result){       
            for(var j=0;j<result.data.list.length;j++){          
                 if(result.data.list[j].shopimage1url != null && result.data.list[j].shopimage1url != undefined  && result.data.list[j].shopimage1url.length>0 ){
                   result.data.list[j].shopimage1url='https://lendgiant.cn/'+result.data.list[j].shopimage1url
            }else{
                result.data.list[j].shopimage1url='https://lendgiant.cn/FileDB/ShopImage/noimage.jpg'
            }
          }
          that.setData({
            jobList:[]
          });
          that.setData({
            jobList:result.data.list
          });
      }
    });
}